package com.jdl.iscm.common;

import lombok.extern.slf4j.Slf4j;
import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;

/**
 * @Author: Ran
 * @Date: 2021/8/23
 **/
@Slf4j
public class Retry implements IRetryAnalyzer {

    //当前次数
    private int currentRetryCount = 0;

    @Override
    public boolean retry(ITestResult iTestResult) {

        //最大重试限制
        int maxRetryCount = 2;
        if (currentRetryCount < maxRetryCount) {
            currentRetryCount++;
            log.info("失败开始执行重试，当前运行第 {} 次", currentRetryCount);
            return true;
        }
        return false;
    }
}
